﻿CREATE FUNCTION dbo.TrackingStatus
(	@ApplID int,
	@VerID int
)
RETURNS varchar(50)
AS
BEGIN

DECLARE @Ret varchar(50)

SELECT @Ret = CASE CV WHEN '1' THEN CONVERT(varchar, thist_Root.DateStamp, 111)+' '+CONVERT(varchar, thist_Root.DateStamp, 108) ELSE '' END
FROM thist_Root
INNER JOIN thist_Child ON thist_Root.HID = thist_Child.HID
WHERE (thist_Root.PK_1 = @ApplID) AND
			(thist_Root.ObjectName = 't_Loan_Verification') AND
			(thist_Child.Key_1 = @VerID) AND
			(thist_Child.CN = 'Checked')
--ORDER BY thist_Root.HID DESC

RETURN @Ret

END
